package com.hdu.hot100.matricx;

public class lc240 {
    class Solution {
        public boolean searchMatrix(int[][] matrix, int target) {
            int curX = 0;
            int curY = matrix[0].length - 1;
            while (curX < matrix.length && curY >= 0)
            {
                if (matrix[curX][curY] == target)
                {
                    return true;
                }
                else if (matrix[curX][curY] > target)
                {
                    curY--;
                }
                else
                {
                    curX++;
                }
            }
            return false;
        }
    }
}
